<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HyperOS丨MIUI 下载加速</title>
    <link href="./bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <script src="./bootstrap.bundle.min.js"
        integrity="sha384-/mhDoLbDldZc3qpsJHpLogda//BVZbgYuw6kof4u2FrCedxOtgRZDTHgHUhOCVim"
        crossorigin="anonymous"></script>
    <script src="./jquery.min.js"></script>

</head>

<body>


    <div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
        <div class="container-fluid">
            <a class="btn btn-success" href="https://roms.miuier.com/zh-cn/devices/" target="MIUI">MIUI下载地址</a>
            <a class="btn btn-success" href="https://hyperos.fans/zh/devices" target="HyperOS">HyperOS下载地址</a>
            <div class="input-group mb-3">
                <br>
            </div>
            <div class="input-group mb-3">
                <span class="input-group-text" id="basic-addon1">源地址</span>
                <input id="oldUrl" type="text" class="form-control"
                    placeholder="https://bigota.d.miui.com/OS1.0.36.0.UNCCNXM/miui_HOUJI_OS1.0.36.0.UNCCNXM_54ab2de231_14.0.zip"
                    aria-label="Username" aria-describedby="basic-addon1">
                <button type="button" class="btn btn-primary" id="btn">加速</button>
            </div>

            <div class="input-group mb-3">
                <input id="newUrl" type="text" class="form-control" placeholder="" aria-label="Username"
                    aria-describedby="basic-addon1">
            </div>
        </div>
    </div>






    <script>
        /**
 * 复制单行内容到粘贴板
 * content : 需要复制的内容
 * message : 复制完后的提示，不传则默认提示"复制成功"
 */
        function copyToClip(content, message) {
            var aux = document.createElement("input");
            aux.setAttribute("value", content);
            document.body.appendChild(aux);
            aux.select();
            document.execCommand("copy");
            document.body.removeChild(aux);
            if (message == null) {
                alert("加速成功");
            } else {
                alert(message);
            }
        };

        $("#btn").click(function () {
            var oldUrl = $("#oldUrl").val();
            //判断oldUrl是否为空    
            if ("" == oldUrl) {
                alert("请填写源地址");

                return;
            }
            //判断oldUrl是否是网址  
            if (oldUrl.indexOf("http") == -1) {
                oldUrl = "https://" + oldUrl;
            }
            //替换https://到/之间的字符  
            newUrl = oldUrl.replace(/https:\/\/[^/]+/, "https://bkt-sgp-miui-ota-update-alisgp.oss-ap-southeast-1.aliyuncs.com");
            $("#newUrl").val(newUrl);
            copyToClip(newUrl);
            $("#oldUrl").val("");
        });
    </script>
</body>

</html>